put line 2 of field "Magic Number" into CurrentMagicNumber
else
put line 1 of field "Teams" into ThatTeam
put line 1 of field "Magic Number" into CurrentMagicNumber
end if
put empty into field "Eliminated"
set the pattern to 12
set the lineSize to 1
get the rect of field "ClinchDates"
put (item 3 of it) + 10 into X1
put (item 2 of it) + 13 into Y1
put 3 into VerticalIncrement
choose select tool
drag from (X1-10 & "," & Y1) to (X1+100 & "," & Y1+(3*21)+1)
doMenu "Fill"
doMenu "Cut Picture"
choose browse tool
if CurrentMagicNumber is "*" then
put "Already" & return & "Eliminated!" into field "Eliminated"
put empty into field "ClinchDates"
put empty into field "ClinchProbVals"
else
put DivisionOfTeam(ThisTeam) into ThisDivision
put word 1 of ThisDivision into League
put word 1 to 2 of item 2 of field "Date" into CurrentDate
put "Oct 3" into LastDate
put CurrentDate & ", 1988" into CurrentDateInSeconds
convert CurrentDateInSeconds to seconds
put LastDate & ", 1988" into LastDateInSeconds
convert LastDateInSeconds to seconds
put (LastDateInSeconds-CurrentDateInSeconds)/(24*60*60) into NumberOfDates
repeat with x = 1 to 4
get LastDateInSeconds - (4-x)*7*24*60*60
convert it to abbreviated date
put word 1 to 2 of item 2 of it into line x of field "ClinchDates"
end repeat
put "0 .2 .4 .6 .8 1.0" into field "ClinchProbVals"
---------------- put 3 into NumberOfDates ----------------
put CurrentDate & ", 1988" into DateInSeconds
convert DateInSeconds to seconds
repeat with x = 1 to NumberOfDates
put 0.0 into item x of ClinchProbs
put empty into item x of ClinchDates
end repeat
repeat with x = 1 to CurrentMagicNumber+4
put 0.0 into item x of CurrentDateProbs
end repeat
put 1.0 into item CurrentMagicNumber of CurrentDateProbs
-- here's where you put the preface --
choose line tool
repeat with x = 0 to 3
drag from (X1 & "," & Y1+(3*x*7)) to (X1+100 & "," & Y1+(3*x*7))
if x<3 then
get 6
else
get 0
end if
repeat with y = 0 to it
put x*7+y into z
drag from (X1-10 & "," & Y1+(3*z)) to (X1-5 & "," & Y1+(3*z))
end repeat
end repeat
repeat with x = 0 to 5
drag from (X1+x*20 & "," & Y1) to (X1+x*20 & "," & Y1+(3*21))
end repeat
choose select tool
put (item 1 of line 1 of field "ClinchDates") & ", 1988" into FirstDate
convert FirstDate to Seconds
put empty into field "MostProbableClinch"
put 0.0 into MostProbable
put 0 into field "TotalClinchProb"
repeat with NextDate = 1 to NumberOfDates
add 24*60*60 to DateInSeconds
put DateInSeconds into DateXX
convert DateXX to abbreviated date
put word 1 to 2 of item 2 of DateXX into DateXX
put GamesOnDate(DateXX,ThisLeague) into DateGames
-- put DateGames into msg
put 1.0 into P0
put 0.0 into P1
put 0.0 into P2
put 0.0 into P3
put 0.0 into P4
repeat with x = 1 to the number of lines in DateGames
get line x of DateGames
-- put it into msg
if (ThisTeam is in it) and (ThatTeam is in it) then
put ProbWin(it,ThisTeam) into Q0
put 0.0 into Q1
put 1.0-Q0 into Q2
else if ThisTeam is in it then
put ProbWin(it,ThisTeam) into Q0
put 1.0-Q0 into Q1
put 0.0 into Q2
else if ThatTeam is in it then
put ProbLose(it,ThatTeam) into Q0
put 1.0-Q0 into Q1
put 0.0 into Q2
else
put 1.0 into Q0
put 0.0 into Q1
put 0.0 into Q2
end if
-- ask "Previous P: " & P0 & "," & P1 & "," & P2
-- ask "New Q: " & Q0 & "," & Q1 & "," & Q2
put P4*Q0 + P3*Q1 + P2*Q2 into P4
put P3*Q0 + P2*Q1 + P1*Q2 into P3
put P2*Q0 + P1*Q1 + P0*Q2 into P2
put P1*Q0 + P0*Q1 into P1
put P0*Q0 into P0
end repeat
repeat with x = 1 to CurrentMagicNumber+2
put item x of CurrentDateProbs into item x of PreviousDateProbs
end repeat
get ((P1+P2+P3+P4)*(item 1 of PreviousDateProbs)) + ((P2+P3+P4)*(item 2 of PreviousDateProbs)) + ((P3+P4)*(item 3 of PreviousDateProbs)) + (P4*(item 4 of PreviousDateProbs))
if (it>0.0) and ((item NextDate of ClinchProbs)=0.0) then
put it into item NextDate of ClinchProbs
put it into NonZeroProb
put DateXX & ", 1988" into NonZeroDate
add NonZeroProb to field "TotalClinchProb"
if NonZeroProb>0 then
if NonZeroProb>MostProbable then
put NonZeroProb into MostProbable
put item 1 of NonZeroDate & ": " & (round (NonZeroProb*1000.0))/1000.0 into field "MostProbableClinch"
end if
convert NonZeroDate to Seconds
put (NonZeroDate-FirstDate)/(24*60*60) into DaysAfterFirst
put Y1+DaysAfterFirst*VerticalIncrement into PlotLineY
put round(NonZeroProb*100) into PlotLineLength
if PlotLineLength=0 then put 1 into PlotLineLength
put X1 & "," & PlotLineY-1 into UpperLeft
put X1+PlotLineLength & "," & PlotLineY into LowerRight
drag from UpperLeft to LowerRight
doMenu "Fill"
end if
end if
put DateXX & ":" & (item NextDate of ClinchProbs) into msg
repeat with NextNumber = 1 to CurrentMagicNumber
get (P0*(item NextNumber of PreviousDateProbs)) + (P1*(item NextNumber+1 of PreviousDateProbs)) + (P2*(item NextNumber+2 of PreviousDateProbs)) + (P3*(item NextNumber+3 of PreviousDateProbs)) + (P4*(item NextNumber+4 of PreviousDateProbs))
put it into item NextNumber of CurrentDateProbs
end repeat
end repeat
hide msg
choose browse tool
end if
put field "Date" into field "Clinch Date"
end mouseUp
-- part 18 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=393 top=272 right=287 bottom=502
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 10
-- style flags: 256
-- line height: 13
-- part name: MostProbableClinch
-- part 22 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=414 top=313 right=328 bottom=501
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 10
-- style flags: 256
-- line height: 13
-- part name: TotalClinchProb
-- part 23 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=14 top=88 right=201 bottom=92
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Teams
-- part 24 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=105 top=88 right=201 bottom=140
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Wins
-- part 25 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=147 top=89 right=202 bottom=182
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Losses Bold
-- part 26 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=200 top=88 right=201 bottom=250
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Percent Bold
-- part 29 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=336 top=88 right=201 bottom=375
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Games Left
-- part 30 (field)
-- low flags: 00
-- high flags: 0000
-- rect: left=12 top=32 right=59 bottom=273
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 18
-- style flags: 768
-- line height: 24
-- part name: Team
-- part 31 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=14 top=88 right=201 bottom=92
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Teams Bold
----- HyperTalk script -----
on mouseUp
put LineOfMouseClick("Teams") into WhichLine
set the cursor to 4
get line WhichLine of field "Teams"
if it is empty then get line WhichLine of field "Teams Bold"
if it is not empty then go to card it
end mouseUp
-- part 32 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=105 top=88 right=201 bottom=140
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Wins Bold
-- part 34 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=273 top=88 right=201 bottom=300
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Games Behind
-- part 35 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=273 top=88 right=201 bottom=300
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Games Behind Bold
-- part 36 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=299 top=88 right=201 bottom=332
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 16
-- part name: Games Behind - Half
-- part 37 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=299 top=88 right=201 bottom=331
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 256
-- line height: 16
-- part name: Games Behind - Half Bold
-- part 38 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=336 top=88 right=201 bottom=375
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Games Left Bold
-- part 39 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=147 top=89 right=202 bottom=182
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Losses
-- part 40 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=200 top=88 right=201 bottom=250
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Percent
-- part 41 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=388 top=88 right=201 bottom=423
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Magic Number
----- HyperTalk script -----
on mouseUp
set the cursor to 4
put the short name of this card into WhichTeam
repeat with WhichLine = 1 to 7
if line WhichLine of field "Teams Bold" is WhichTeam
then put WhichLine into TeamLine
end repeat
put (the number of lines in field "Teams") into MaxTeam
if TeamLine > MaxTeam then put TeamLine into MaxTeam
repeat with WhichLine = 1 to MaxTeam
if WhichLine is TeamLine then
put line WhichLine of field "Games Left Bold" into GamesLeft
put line WhichLine of field "Wins Bold" into Wins
put line WhichLine of field "Losses Bold" into Losses
else if line WhichLine of field "Teams" is not empty then
put line WhichLine of field "Games Left" into GamesLeft
put line WhichLine of field "Wins" into Wins
put line WhichLine of field "Losses" into Losses
end if
put GamesLeft into item WhichLine of AllGamesLeft
put Wins-Losses into item WhichLine of AllDifferences
if line WhichLine of field "Teams" is empty then
put item WhichLine of AllDifferences into ThisDifference
put item WhichLine of AllGamesLeft into ThisGamesLeft
end if
end repeat
put empty into field "Magic Number"
repeat with WhichLine = 1 to MaxTeam
put item WhichLine of AllDifferences into WinLossDifference
put item WhichLine of AllGamesLeft into GamesLeft
get ThisGamesLeft+GamesLeft+WinLossDifference-ThisDifference
put (it/2)+1 into MagicNumber
if MagicNumber > (GamesLeft+ThisGamesLeft)
then put "*" into MagicNumber
if line WhichLine of field "Teams" is empty
then put "--" into MagicNumber
put MagicNumber into line WhichLine of field "Magic Number"